<template>
  <el-dialog :title="!dataForm.id ? '新建' : isDetail ? '详情' : '编辑'" :close-on-click-modal="false" :visible.sync="visible" class="cu-dialog cu-dialog_center" lock-scroll width="1100px">
    <el-row :gutter="15" class="">
      <el-form ref="elForm" :model="dataForm" size="small" label-width="100px" label-position="right" :disabled="!!isDetail" :rules="rules">
        <el-col :span="8">
          <el-form-item label="校区品牌" prop="brand">
            <el-select v-model="dataForm.brand" placeholder="请选择校区品牌" @change="handleChangeBrand" filterable clearable required :style="{ width: '100%' }">
              <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="校区名称" prop="campusId">
            <el-select v-model="dataForm.campusId" placeholder="请选择" filterable clearable required :style="{ width: '100%' }" :loading="campusLoading" @focus="loadCampusOptions">
              <el-option v-for="(item, index) in campusOptions" :key="index" :label="item.fullName" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="师训名称" prop="trainId">
            <el-select v-model="dataForm.trainId" placeholder="请选择" filterable clearable required :style="{ width: '100%' }">
              <el-option v-for="(item, index) in trainOptions" :key="index" :label="item.title" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <!--<el-col :span="24">
          <el-form-item label-width="0">
            <groupTitle content-position="left" content="老师信息"></groupTitle>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="老师姓名" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="性别" prop="gender">
            <el-select v-model="dataForm.gender" placeholder="请选择" clearable :style='{"width":"100%"}'>
              <el-option v-for="(item, index) in genderOptions" :key="index" :label="item.fullName"
                         :value="item.enCode">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="职位" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="联系方式" prop="mobile">
            <el-input v-model="dataForm.mobile" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="身份证号码" prop="idCard">
            <el-input v-model="dataForm.idCard" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="证件照" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>-->
        <!--        <el-col :span="24">
          <el-form-item label-width="0">
            <groupTitle content-position="left" content="参训信息"></groupTitle>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="参训类型" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="师训名称" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24" >
          <el-form-item label="新增师训名" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="参训期数" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12" >
          <el-form-item label="结业日期" prop="teacherName">
            <el-input v-model="dataForm.teacherName" placeholder="请输入" clearable :style='{"width":"100%"}'>
            </el-input>
          </el-form-item>
        </el-col>-->
        <el-col :span="24">
          <el-form-item label-width="0">
            <groupTitle content-position="left" content="老师信息"></groupTitle>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label-width="0" prop="teachers">
            <el-table :data="dataForm.teachers" size="mini" class="cu-common-table" empty-text="点击下方“添加老师”按钮可选择报名老师">
              <el-table-column prop="teacherId" label="老师编号" />
              <el-table-column prop="teacherName" label="老师姓名" />
              <el-table-column prop="gender" label="性别" align="center">
                <template slot-scope="scope">
                  {{ scope.row.gender == 1 ? '男' : '女' }}
                </template>
              </el-table-column>
              <el-table-column prop="campusName" label="校区" align="center" />
              <el-table-column prop="mobile" label="手机号码" align="center" width="150" />
              <el-table-column prop="idCard" label="身份证号码" align="center" width="180" />
              <el-table-column v-if="custom.hasP('photo')" prop="photo" label="证件照" align="left" width="120">
                <template slot-scope="scope">
                  <el-image v-if="scope.row.idPhoto != null" :src="'https://qiniu.anqinyun.com/' + scope.row.idPhoto" style="width: 80px" fit="scale-down" lazy :preview-src-list="['https://qiniu.anqinyun.com/' + scope.row.idPhoto]"></el-image>
                </template>
              </el-table-column>
              <el-table-column label="操作" width="80">
                <template slot-scope="scope">
                  <el-button size="mini" type="text" class="cu-table-delBtn" @click="handleDelTrainOrderItemEntityList(scope.$index)">删除</el-button>
                </template>
              </el-table-column>
            </el-table>
            <div class="table-actions" @click="openTeacherBox">
              <el-button type="text" icon="el-icon-plus">新增</el-button>
            </div>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" @click="dataFormSubmit()" v-if="!isDetail">确 定</el-button>
    </span>
    <teacher-box :visible.sync="teacherBoxVisible" @closeForm="closeForm" :trainId="dataForm.trainId" :campusId="dataForm.campusId" ref="teacherBox" />
  </el-dialog>
</template>
<script>
export { default } from './index.js'
</script>
<style scoped>
.el-time-spinner__wrapper {
  width: 100% !important;
}
/* @import url(index.scss); */
</style>
